member=[{"name":"zhangsan","password":"123456","balance":10000},
        {"name":"lisi","password":"111111","balance":6000},
        {"name":"wangwu","password":"222222","balance":5000}
        ]
#登录函数
def land(sName,sPassword):
    global member
    i=0
    for user in member:
        if sName==user["name"]:
            #检验用户名是否存在
            if sPassword==user["password"]:
                #检验密码是否正确
                print("欢迎使用!")
                return i
            else:
                print("密码错误,请重新登录")
                return -2
        else:
            print("账号错误,请重新登录")
            return -1
    i +=1
#取款函数
def searchmoney(user_id):
    global member
    print("你的余额为{}元！".format(member[user_id]["balance"]))
#存款函数
def savemoney(user_id):
    global member
    while True:
        money =input("请输入您的存款金额:")
        if float(money)<=0:
            print("请输入大于0的金额")
        else:
            member[user_id]["balance"]+= int(money)
            print("您已存款{}元,余额为{}元.".format(money,member[user_id]["balance"]))
            break
#取款函数
def takemoney(uesr_id):
    global member
    while True:
        money=input("请输入你的取款金额:")
        if float(money)<=0:
            print("请输入大于0的金额")
        elif float(money)>member[user_id]["balance"]:
            print("不好意思,您的余额不足")
        else:
            member[user_id]["balance"]-= int(money)
            print("您已取款{}元,余额为{}元.".format(money,member[user_id]["balance"]))
            break

#退出登录函数

    
#功能选择界面
while True:
    #输入初始界面
    print("="*12,"自动取款机管理系统","="*14)
    user_name=input("请输入用户名：")
    user_password=input("请输入密码:")
    user_id= land(user_name,user_password)
    if user_id<0:
        continue
    #功能选择界面
    while True:
        print("="*12,"请选择业务","="*14)
        print("{0:1}{1:13}{2:15}".format("","1余额查询","2,存款"))
        print("{0:1}{1:13}{2:15}".format("","3取款","4,退出登录"))
        print("="*26)
        key=input("请选择你的业务:")
        if key=="1":
            searchmoney(user_id)
            input("按回车继续")
        elif key=="2":
            savemoney(user_id)
            input("按回车继续")
        elif key=="3":
            takemoney(user_id)
            input("按回车继续")
        elif key=="4":
             break
            
            
        
        
    
                            
